<?php
require('../vendor/autoload.php');

use BitWasp\Bitcoin\Key\PrivateKeyFactory;
use BitWasp\Bitcoin\Script\ScriptFactory;
use BitWasp\Bitcoin\Network\NetworkFactory;
use BitWasp\Bitcoin\Address\ScriptHashAddress;

$network = NetworkFactory::bitcoinRegtest();

$prv = PrivateKeyFactory::create(true);
$pub = $prv->getPublicKey();
$redeemScript = ScriptFactory::create()
                   ->push($pub->getBuffer())
                   ->op('OP_CHECKSIG')
                   ->getScript();
$p2sh = new ScriptHashAddress($redeemScript->getScriptHash());
echo 'p2sh address => ' . $p2sh->getAddress($network) . PHP_EOL;